package com.superbytecode.cloud.rocketmq.scan;

import org.springframework.beans.factory.FactoryBean;

import static com.superbytecode.cloud.rocketmq.producer.MQTemplateInvocationHandler.newProxyInstance;

/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: beacon-cloud
 * @Package: com.superbytecode.cloud.rocketmq
 * @ClassName: MQFactoryBean
 * @Description: []
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/11/1 23:17
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
public class MQFactoryBean<T> implements FactoryBean<T> {
    public final Class<T> beanType;

    public MQFactoryBean(Class<T> beanType) {
        this.beanType = beanType;
    }

    @Override
    @SuppressWarnings("unchecked")
    public T getObject() throws Exception {
        return (T) newProxyInstance(beanType);
    }

    @Override
    public Class<?> getObjectType() {
        return beanType;
    }
}